import random

def bucketSort(A, N, buckets, M):
	for i in range(N):
		buckets[A[i]] += 1
	R = []
	for j in range(M):
		R.extend(j for k in range(buckets[j]))
	return R


A = [random.randint(1, 1000) for k in range(30000)]
B = bucketSort(A, len(A), [0] * (max(A) + 1), (max(A) + 1))